//
//    Copyright (C) Microsoft.  All rights reserved.
//
//
// Module Name:
//
//      PbdaErrors.h
//
// Abstract:
//
//      Interface specific HRESULT error codes for PBDA.
//
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include <winapifamily.h>

#pragma region Desktop Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)


    // Interface specific SUCCESS and ERROR macros
#define MAKE_BDA_S_ITF_HRESULT(x)   MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, (x))
#define MAKE_BDA_E_ITF_HRESULT(x)   ( (MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, (x))) | 0x40000000 )    // setting bit 30 to 1

    
//Success HResults
const HRESULT MSDRI_S_MMI_PENDING                  = MAKE_BDA_S_ITF_HRESULT(0x02);
const HRESULT MSDRI_S_PENDING                      = MAKE_BDA_S_ITF_HRESULT(0x01);


//Error HResults
const HRESULT BDA_E_FAILURE                        = MAKE_BDA_E_ITF_HRESULT(0x0001);
const HRESULT BDA_E_NOT_IMPLEMENTED                = MAKE_BDA_E_ITF_HRESULT(0x0002);
const HRESULT BDA_E_NO_SUCH_COMMAND                = MAKE_BDA_E_ITF_HRESULT(0x0003);
const HRESULT BDA_E_OUT_OF_BOUNDS                  = MAKE_BDA_E_ITF_HRESULT(0x0004);
const HRESULT BDA_E_INVALID_SCHEMA                 = MAKE_BDA_E_ITF_HRESULT(0x0005);
const HRESULT BDA_E_INVALID_HANDLE                 = MAKE_BDA_E_ITF_HRESULT(0x0006);
const HRESULT BDA_E_INVALID_TYPE                   = MAKE_BDA_E_ITF_HRESULT(0x0007);
const HRESULT BDA_E_READ_ONLY                      = MAKE_BDA_E_ITF_HRESULT(0x0008);
const HRESULT BDA_E_ACCESS_DENIED                  = MAKE_BDA_E_ITF_HRESULT(0x0009);
const HRESULT BDA_E_NOT_FOUND                      = MAKE_BDA_E_ITF_HRESULT(0x000A);
const HRESULT BDA_E_BUFFER_TOO_SMALL               = MAKE_BDA_E_ITF_HRESULT(0x000B);
const HRESULT BDA_E_OUT_OF_RESOURCES               = MAKE_BDA_E_ITF_HRESULT(0x000C);
const HRESULT BDA_E_OUT_OF_MEMORY                  = MAKE_BDA_E_ITF_HRESULT(0x000D);
const HRESULT BDA_E_DISABLED                       = MAKE_BDA_E_ITF_HRESULT(0x000E);
const HRESULT BDA_E_NO_HANDLER                     = MAKE_BDA_E_ITF_HRESULT(0x000F);
const HRESULT BDA_E_INVALID_LANGUAGE               = MAKE_BDA_E_ITF_HRESULT(0x0010);
const HRESULT BDA_E_TIMEOUT_ELAPSED                = MAKE_BDA_E_ITF_HRESULT(0x0011);
const HRESULT BDA_E_NO_MORE_EVENTS                 = MAKE_BDA_E_ITF_HRESULT(0x1001);
const HRESULT BDA_E_NO_MORE_DATA                   = MAKE_BDA_E_ITF_HRESULT(0x1002);
const HRESULT BDA_E_TUNER_INITIALIZING             = MAKE_BDA_E_ITF_HRESULT(0x3001);
const HRESULT BDA_E_TUNER_REQUIRED                 = MAKE_BDA_E_ITF_HRESULT(0x3002);
const HRESULT BDA_E_TUNER_CONFLICT                 = MAKE_BDA_E_ITF_HRESULT(0x3003);
const HRESULT BDA_E_INVALID_TUNE_REQUEST           = MAKE_BDA_E_ITF_HRESULT(0x3004);
const HRESULT BDA_E_INVALID_ENTITLEMENT_TOKEN      = MAKE_BDA_E_ITF_HRESULT(0x4001);
const HRESULT BDA_E_INVALID_CAPTURE_TOKEN          = MAKE_BDA_E_ITF_HRESULT(0x4002);
const HRESULT BDA_E_WOULD_DISRUPT_STREAMING        = MAKE_BDA_E_ITF_HRESULT(0x4003);
const HRESULT BDA_E_INVALID_PURCHASE_TOKEN         = MAKE_BDA_E_ITF_HRESULT(0x4004);
const HRESULT BDA_E_IPNETWORK_ERROR                = MAKE_BDA_E_ITF_HRESULT(0x5001);
const HRESULT BDA_E_IPNETWORK_ADDRESS_NOT_FOUND    = MAKE_BDA_E_ITF_HRESULT(0x5002);
const HRESULT BDA_E_IPNETWORK_TIMEOUT              = MAKE_BDA_E_ITF_HRESULT(0x5003);
const HRESULT BDA_E_IPNETWORK_UNAVAILABLE          = MAKE_BDA_E_ITF_HRESULT(0x5004);
const HRESULT BDA_E_TUNE_FAILED_SDV01              = MAKE_BDA_E_ITF_HRESULT(0x6001);
const HRESULT BDA_E_TUNE_FAILED_SDV02              = MAKE_BDA_E_ITF_HRESULT(0x6002);
const HRESULT BDA_E_TUNE_FAILED_SDV03              = MAKE_BDA_E_ITF_HRESULT(0x6003);
const HRESULT BDA_E_TUNE_FAILED_SDV04              = MAKE_BDA_E_ITF_HRESULT(0x6004);
const HRESULT BDA_E_TUNE_FAILED_SDV05              = MAKE_BDA_E_ITF_HRESULT(0x6005);
const HRESULT BDA_E_TUNE_FAILED_SDV06              = MAKE_BDA_E_ITF_HRESULT(0x6006);
const HRESULT BDA_E_TUNE_FAILED_SDV07              = MAKE_BDA_E_ITF_HRESULT(0x6007);
const HRESULT BDA_E_TUNE_FAILED_SDV08              = MAKE_BDA_E_ITF_HRESULT(0x6008);
const HRESULT BDA_E_TUNE_FAILED_SDVFF              = MAKE_BDA_E_ITF_HRESULT(0x60FF);



//WMDRM Error HResults
const HRESULT BDA_E_WMDRM_INVALID_SIGNATURE        = MAKE_BDA_E_ITF_HRESULT(0xF001);
const HRESULT BDA_E_WMDRM_INVALID_CERTIFICATE      = MAKE_BDA_E_ITF_HRESULT(0xF002);
const HRESULT BDA_E_WMDRM_INVALID_VERSION          = MAKE_BDA_E_ITF_HRESULT(0xF004);
const HRESULT BDA_E_WMDRM_INVALID_DATE             = MAKE_BDA_E_ITF_HRESULT(0xF005);
const HRESULT BDA_E_WMDRM_INVALID_PROXIMITY        = MAKE_BDA_E_ITF_HRESULT(0xF006);
const HRESULT BDA_E_WMDRM_KEY_ID_NOT_FOUND         = MAKE_BDA_E_ITF_HRESULT(0xF008);


#define IS_BDAERROR(Status)   (  (((unsigned long)(Status)) >> 31 == SEVERITY_ERROR)   && ( (((Status) >> 16) & 0x1fff)==  FACILITY_ITF) \
                               &&(((Status) & 0x40000000) == 0x40000000)    )    // bit 30 has to be 1

#define IS_BDASUCCESS(Status) (  (((unsigned long)(Status)) >> 31 == SEVERITY_SUCCESS) && ( (((Status) >> 16) & 0x1fff) ==  FACILITY_NULL))

#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
#pragma endregion

